const s = {
  v: `
          attribute vec4 a_position;
          attribute float a_translation;
          attribute float a_scalin;
          void main() {
              gl_Position = vec4((a_position.x + a_translation) * (a_scalin*a_scalin) ,(a_position.y+ a_translation) * (a_scalin*a_scalin), a_position.z, 1.0);
          }
      `,
  f: `
      precision mediump float;
      void main() {
          gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0);
      }
      `,
}
// 得到着色器程序
const program = getProgram(gl, s)
// // 获取着色器程序中的变量
const a_position = gl.getAttribLocation(program, "a_position")
const a_translation = gl.getAttribLocation(program, "a_translation")
const a_scalin = gl.getAttribLocation(program, "a_scalin")
// //TODO 创建顶点数据
const positionData = new Float32Array([
  -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5,
])
// // 创建缓冲对象
const buffer = gl.createBuffer()
// // 绑定缓冲对象
gl.bindBuffer(gl.ARRAY_BUFFER, buffer)
// // 填充缓冲对象
gl.bufferData(gl.ARRAY_BUFFER, positionData, gl.STATIC_DRAW)
// // 配置变量
gl.vertexAttribPointer(a_position, 2, gl.FLOAT, false, 0, 0)
// // 启用变量
gl.enableVertexAttribArray(a_position)
let i = -1

// 动画循环
function animate() {
  i += 0.05
  if (i > 1) {
    i = -1
  }
  // gl.vertexAttrib1f(a_translation, i)
  gl.vertexAttrib1f(a_scalin, i)
  gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4)

  requestAnimationFrame(animate)
}
animate()
